// src/api/merchantAPI.js
import http from '@/utils/http'

/**
 * 添加商户
 * @param {Object} params - 商户信息对象
 */
export const addMerchantAPI = (params) => {
  return http.post('/merchant-client/cms/merchantInfo/add', params)
}

/**
 * 修改商户资料
 * @param {number} id - 商户ID
 * @param {Object} params - 商户信息对象
 */
export const updateMerchantAPI = (id, params) => {
  return http.post(`/merchant-client/cms/merchantInfo/update?id=${id}`, params)
}

/**
 * 删除商户
 * @param {number} id - 商户ID
 */
export const deleteMerchantAPI = (id) => {
  return http.post(`/merchant-client/cms/merchantInfo/delete?id=${id}`)
}

/**
 * 切换商户状态
 * @param {number} id - 商户ID
 */
export const toggleMerchantStatusAPI = (id) => {
  return http.post(`/merchant-client/cms/merchantInfo/toggleStatus?id=${id}`)
}

/**
 * 获取商户详情
 * @param {number} id - 商户ID
 */
export const getMerchantAPI = (id) => {
  return http.post(`/merchant-client/cms/merchantInfo/get?id=${id}`)
}

/**
 * 获取所有商户信息
 */
export const listAllMerchantsAPI = () => {
  return http.post('/merchant-client/cms/merchantInfo/listAll')
}

/**
 * 根据商户名称模糊匹配
 * @param {string} name - 商户名称
 */
export const searchMerchantByNameAPI = (name) => {
  return http.post('/merchant-client/cms/merchantInfo/searchByName', {}, {
    params: {
      name: name || undefined
    }
  })
}